package com.cmc.cloud.cmclink.doc.controller.admin.si;

import com.cmc.cloud.cmclink.doc.service.si.ConfirmNoticeDetailService;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticedetailvo.ConfirmNoticeDetailCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticedetailvo.ConfirmNoticeDetailPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticedetailvo.ConfirmNoticeDetailRespVO;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticedetailvo.ConfirmNoticeDetailUpdateReqVO;
import com.cmes.framework.operatelog.core.annotations.OperateLog;
import com.cmes.framework.operatelog.core.enums.OperateTypeEnum;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import java.util.*;


import com.cmes.framework.common.pojo.PageResult;

import com.cmc.cloud.cmclink.doc.entity.ConfirmNoticeDetailDO;
import com.cmc.cloud.cmclink.doc.convert.ConfirmNoticeDetailConvert;


/**
 * 确认装货港更改通知子前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - 确认装货港更改通知子")
@RestController
@Validated
@RequestMapping("/admin-api/doc/v1/confirm-notice-detail")
public class ConfirmNoticeDetailController {

    @Resource
    private ConfirmNoticeDetailService confirmNoticeDetailService;

    @Operation(summary = "创建确认装货港更改通知子")
    @OperateLog(type = OperateTypeEnum.CREATE)
	@PostMapping("/create")
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:create')")
    public CommonResult<Void> createConfirmNoticeDetail(@Valid @RequestBody ConfirmNoticeDetailCreateReqVO createReqVO) {
        confirmNoticeDetailService.createConfirmNoticeDetail(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新确认装货港更改通知子")
    @OperateLog(type = OperateTypeEnum.UPDATE)
	@PostMapping("/update")
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:update')")
    public CommonResult<Void> updateConfirmNoticeDetail(@Valid @RequestBody ConfirmNoticeDetailUpdateReqVO updateReqVO) {
        confirmNoticeDetailService.updateConfirmNoticeDetail(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除确认装货港更改通知子")
    @OperateLog(type = OperateTypeEnum.DELETE)
	@PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:delete')")
    public CommonResult<Void> deleteConfirmNoticeDetail(@PathVariable("id") Long id) {
        confirmNoticeDetailService.deleteConfirmNoticeDetail(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得确认装货港更改通知子")
    @OperateLog(type = OperateTypeEnum.GET)
	@GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:query')")
    public CommonResult<ConfirmNoticeDetailRespVO> getConfirmNoticeDetail(@PathVariable("id") Long id) {
        ConfirmNoticeDetailDO confirmNoticeDetail = confirmNoticeDetailService.getConfirmNoticeDetail(id);
        return CommonResult.success(ConfirmNoticeDetailConvert.INSTANCE.convert(confirmNoticeDetail));
    }

    @Operation(summary = "获得确认装货港更改通知子列表")
    @OperateLog(type = OperateTypeEnum.GET)
	@GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:query')")
    public CommonResult<List<ConfirmNoticeDetailRespVO>> getConfirmNoticeDetailList(@RequestParam("ids") Collection<Long> ids) {
        List<ConfirmNoticeDetailDO> list = confirmNoticeDetailService.getConfirmNoticeDetailList(ids);
        return CommonResult.success(ConfirmNoticeDetailConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得确认装货港更改通知子分页")
    @OperateLog(type = OperateTypeEnum.GET)
	@GetMapping("/page")
    @PreAuthorize("@ss.hasPermission('doc:confirm-notice-detail:query')")
    public CommonResult<PageResult<ConfirmNoticeDetailRespVO>> getConfirmNoticeDetailPage(@Valid ConfirmNoticeDetailPageReqVO pageVO) {
        PageResult<ConfirmNoticeDetailDO> pageResult = confirmNoticeDetailService.getConfirmNoticeDetailPage(pageVO);
        List<ConfirmNoticeDetailRespVO> results = ConfirmNoticeDetailConvert.INSTANCE.convertList(pageResult.getList());
        return CommonResult.success(new PageResult<>(results,pageResult.getTotal()));
    }
}
